package cn.ipanel.bigdata.utils

import cn.ipanel.bigdata.boot.config.Configuration

/**
 * Author: lzz
 * Date: 2021/11/18 16:41
 */
object Dictionary {

  final val F_DATE = "f_date"
  final val F_PERIOD_TIME = "f_period_time"

  final lazy val ACTIVE_THRESHOLD: Int = 2
  final lazy val LONG: Long = 0L
  final lazy val NONE: String = "None"
  final lazy val INT: Int = 0
  final lazy val UNKNOWN: String = "unknown"
  final lazy val INVALID_INT: Int = Integer.MIN_VALUE
  final lazy val INVALID_LONG: Long = Long.MinValue

  final lazy val F_DEVICE_ID = "f_device_id"
  final lazy val F_REGION = "f_region"
  final lazy val F_STATUS = "f_status"
  final lazy val TASK_EXECUTION_TABLE_NAME = "default"

  final lazy val MYSQL_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"

  case object Service {
    final lazy val SERVICE_ONLINE         = 301       // 设备上线
    final lazy val SERVICE_OFFLINE        = 303       // 设备离线
    final lazy val SERVICE_HEARTBEAT      = 701       // 心跳
    final lazy val SERVICE_HOME           = 900       // 家庭变更
    final lazy val SERVICE_DEVICE         = 901       // 设备变更
    final lazy val SERVICE_ALARM          = 902       // 告警
    final lazy val SERVICE_AREA           = 903       // 区域变更
    final lazy val SERVICE_NET            = 904       // 告警
  }

  protected[utils] trait Action {
    final lazy val FIELD_ACTION        = "A"     // 0 删除，1 新增，2 修改
    final lazy val FIELD_STATUS_MODIFY_TIME   = "ST"    // 创建，修改，删除时间，unix时间戳，精确到秒，跟上报时间不一样
  }

  case object Device extends Action {
    final lazy val FIELD_CLASS         = "T2"    // class 分类
    final lazy val FIELD_AREA_CODE     = "C"     // 区域码
  }

  case object Home extends Action {
    final lazy val FIELD_HOME_ID       = "H"     // 家庭id
    final lazy val FIELD_AREA_CODE     = "C"     // 区域码
  }

  case object Network {
    final lazy val FIELD_LOST_PACKET_RATE        = "P"     // 丢包率
  }

  case object Area extends Action {
    final lazy val FIELD_AREA_CODE     = "C"     // 区域码
    final lazy val FIELD_AREA_NAME     = "N"     // 区域名称
    final lazy val FIELD_PARENT_CODE   = "P"     // 父区域码
    final lazy val FIELD_AREA_LEVEL    = "L"     // 区域等级
  }

  /**
   * 业务数据状态
   */
  case object BusState {
    final lazy val DEL            = 0                       // 删除
    final lazy val ADD            = 1                       // 新增
    final lazy val MOD            = 2                       // 修改
    final lazy val INVALID        = INVALID_INT             // 非法状态，正常情况不使用
  }

  /**
   * 设备状态
   */
  case object DeviceStat {
    final lazy val OFFLINE           = 0                    // 设备离线
    final lazy val ONLINE            = 1                    // 设备在线
  }

}